using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using PlugNT.Safe;
using PlugNT.Cms.Custom;
using PlugNT.Database;
using PlugNT.Cms.Model;

namespace PlugNT.Cms.BLL
{
    public class FriendLink
    {

        internal static readonly PlugNT.Cms.DAL.FriendLink dal = new PlugNT.Cms.DAL.FriendLink();







        public static string CreateLinks(int classId, string splitString)
        {
            return dal.CreateLinks(classId, splitString);
        }







        public void RemoveLinks()
        {
            dal.RemoveLinks();
        }






        public bool RemoveLinks(int classId)
        {
            return PlugNT.Cms.DAL.FriendLink.RemoveLinks(classId);
        }






        public FriendLinkInfo GetFriendLinkInfo(int id)
        {
            return dal.GetFriendLinkInfo(id);

        }











        public bool Add(FriendLinkInfo model)
        {
            return dal.Add(model);
        }






        public bool Update(FriendLinkInfo model)
        {
            return dal.Update(model);
        }






        public bool Delete(int id)
        {
            return dal.Delete(id);
        }






        public bool DeleteByClassId(int classId)
        {
            return dal.DeleteByClassId(classId);
        }


        public DataTable GetList(int sysModelId, int topCount, int currPageCount, int classId, out int recordCount)
        {
            StringBuilder andWhere = new StringBuilder();

            if (classId>0)
            {
                andWhere.Append(" and [class_id]=" + classId);
            }
            recordCount = dal.GetCount(sysModelId, andWhere.ToString());
            LeftJoinInfo joininfo = new LeftJoinInfo(FriendLinkClass.GetTableName(), "name", "class_id", "id", "");
            return dal.GetList(sysModelId, topCount, currPageCount, andWhere.ToString(), joininfo);
        }

    }
}

